package com.tangqiao;

import java.awt.image.BufferedImage;

public class TurnJudger {
	private static final int PX = 173;
	private static final int PY = 432;
	private static final int OVER_X = 400;
	private static final int OVER_Y = 400;
	private static final int OVER_COLOR = -460552;
	private static final int BOARD_COLOR = -5722976;
	private static final int RED_COLOR = -3624808;
	private static final int BLACK_COLOR = -1527680; // -6249320
	public static boolean isMyTurn(BufferedImage sub) {
		int v;
		v = sub.getRGB(OVER_X, OVER_Y);
		if (v == OVER_COLOR) {
			System.out.println("Game over.");
			System.exit(0);
		}
		v = sub.getRGB(PX, PY);
	    if ( v == BOARD_COLOR || v == -6249320)
	    	return false;
	    else if (v == RED_COLOR || v == BLACK_COLOR)
	    	return true;
	    else {
	    	System.out.println(v);
	    	System.out.println("No chess board.");
	    	System.exit(0);
	    }
		return false;
	}
}
